<?php
class InlogAction extends CommonAction {
	//过滤查询字段
	function _filter(&$map){
		$map['title'] = array('like',"%".$_POST['name']."%");
	}

	public function in(){
		$Inlog          = M('Inlog');
		$data           =  $_REQUEST;
		if(!isset($data['chestId'])||trim($data['chestId'])==''){
			$this->error('请填写临时租柜号!');
		}
		$data['inTime'] = time();
		if($Inlog -> add($data)){
			$this->success('进场成功');
		}
		$this->error('进场失败');
	}
	public function out(){
		$logId  =  $_REQUEST['logId'];
		$Inlog          = M('Inlog');
		$data['outTime'] = time();
		if($Inlog ->where('id='.$logId)->save($data)){
			$this->success('成功离场');
		}
	}

	public function inlog(){
		$Inlog = M('Inlog');
		$count = $Inlog->where('memberId='.$_REQUEST['memberId'])->count();
		if($count>0){
			import ( "@.ORG.Page" );
			$p = new Page ( $count, C('PAGE_SIZE') );
 			$list  = $Inlog->where('memberId='.$_REQUEST['memberId'])->order('id desc')->limit($p->firstRow . ',' . $p->listRows)->select();
			$page = $p->show();
			$this->assign('list',$list);
			$this->assign ( "page", $page );
		}
		$this->display ();
	}

	public function index() {
		//列表过滤器，生成查询Map对象
		$map = $this->_search ();
		if (method_exists ( $this, '_filter' )) {
			$this->_filter ( $map );
		}
		$name=$this->getActionName();
		$model = D ($name);
		if (! empty ( $model )) {
			$this->_list ( $model, $map );
		}
		$this->display ();
		return;
	}

}
?>